home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DNet / DGoClasses.h < prev    next >
Text File  |  1996-07-05  |  9KB  |  321 lines

  1. // DGopherClasses.h
  2. // d.g.gilbert
  3.  
  4. #ifndef __DGOPHERCLASSES__
  5. #define __DGOPHERCLASSES__
  6.  
  7. #include <DGopher.h>
  8. #include <Dvibrant.h>
  9.  
  10.             // Types of objects returned from a Gopher server 
  11.             // This Jack should be private !! implementation only 
  12. enum GopherType {
  13.  kTypeFile         = '0',      // text file  
  14.  kTypeFolder        = '1',      // menu/directory 
  15.  kTypeCSO          = '2',        // CSO phone book service 
  16.  kTypeError        = '3',      // error 
  17.  kTypeBinhex        = '4',        // binhex encoded Macintosh file 
  18.  kTypeUuencode     = '6',      // uuencoded file 
  19.  kTypeQuery        = '7',      // question service 
  20.  kTypeTelnet       = '8',      // telnet service 
  21.  kTypeBinary       = '9',      // binary 
  22.  kTypeSound        = 's',      // sound 
  23.  kTypeImage            = 'I',        // image, probably gif
  24.  kTypeMovie            = ',',        // movie
  25.  kTypeNote            = 'i',        // note, information for directory
  26.  kTypeEndOfData    = '.',      // end of information 
  27.     //experimental
  28.  kTypeGif                = 'g',    // GIF picture
  29.  kTypeWhois       = 'w',    // WHOIS phone book service -- not official, just easy 
  30.  kTypeTn3270      = 'T',     // Telnet variant -- just call diff app ?
  31.  kTypeHtml      = 'h',    // WWW type, ????
  32.  kTypeMime        = 'M',  // Mime, no mac reader yet
  33.  
  34.  kMailType            = 'm',        // mailto, dgg addition for gopherpup
  35.     
  36.     //? obsolete types ?
  37.  kTypeBinhexpc    = '5',  // binhex encoded MSDos file 
  38.  kTypeEvent        = 'e',  // ?? 
  39.  kTypeCal                 = 'c',  // ?? 
  40.  kTypeRedundant = '+',  // a redundant server holding the same information as the previous server
  41.  kTypeNull             = '\0'    // end of data
  42. };
  43.  
  44.  
  45. enum GopherIconID {
  46.     kTextIcon                = 2200,    // resource fork must have these icon/cicon 
  47.     kFolderIcon            = 2201,
  48.     kPhonebookIcon    = 2202, //CSO phonebook
  49.     kDefaultIcon        = 2203,
  50.     kBinhexIcon            = 2204,
  51.     kUuencodeIcon     = 2206,
  52.     kIndexIcon             = 2207,
  53.     kTelnetIcon            = 2208,
  54.     kSoundIcon            = 2212,
  55.     kWhoisPhonebookIcon    = 2213,
  56.     kBinaryIcon            = 2214,
  57.     kImageIcon            = 2215,
  58.     kMovieIcon            = 2216,
  59.     kHTMLIcon            = 2217,
  60.     kNoteIcon                = 2218,
  61.     kFirstIcon            = kTextIcon,
  62.     kLastIcon                = kNoteIcon
  63. };
  64.  
  65. //const    long    kMaxInt                    = 32000;    
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.         // Three primary subclasses for further subclassing... other gopher objects private??            
  73.  
  74. class DFolderGopher : public DGopher {
  75. public:
  76.     DFolderGopher( char ctype, const char* link);
  77.     DFolderGopher();
  78.     DFolderGopher( DFolderGopher* aGopher);
  79.     virtual    void Initialize();    // override 
  80.     virtual DObject* Clone();
  81.     virtual void OpenQuery(); // override 
  82.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  83.     virtual const char* GetKindName();
  84. };
  85.  
  86. class DTextGopher : public DGopher {
  87. public:
  88.     static long    kMacType, kMacSire;
  89.     static char* kSuffix;
  90.     DTextGopher( char ctype, const char* link);
  91.     DTextGopher();
  92.     DTextGopher( DTextGopher* aGopher);
  93.     virtual    void Initialize();    // override 
  94.     virtual DObject* Clone();
  95.     virtual void OpenQuery(); // override 
  96.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  97.     virtual const char* GetKindName();
  98.     static  void InitSignature();     
  99. };
  100.             
  101. class DBinaryGopher : public DGopher {
  102. public:
  103.     static long    kMacType, kMacSire;
  104.     static char* kSuffix;
  105.     DBinaryGopher( char ctype, const char* link);
  106.     DBinaryGopher();
  107.     DBinaryGopher( DBinaryGopher* aGopher);
  108.     virtual    void Initialize();    // override 
  109.     virtual DObject* Clone();
  110.     virtual void OpenQuery(); // override 
  111.     virtual void DrawIcon(Nlm_RecT& area, short size); // override 
  112.     virtual const char* GetKindName();
  113.     static void InitSignature();     
  114. };
  115.             
  116.  
  117.  
  118.  
  119.     // keep specific gopher types private here, so we can add/remove
  120.     // ones as desired... 
  121.     
  122. class DIndexGopher : public DFolderGopher {
  123. public:
  124.     DIndexGopher( char ctype, const char* link);
  125.     DIndexGopher();
  126.     DIndexGopher( DIndexGopher* aGopher);
  127.     virtual    void Initialize();    // override 
  128.     virtual DObject* Clone();
  129.     virtual    void OpenQuery();
  130.     virtual void CloseQuery();
  131.     virtual void InfoTask();
  132.     virtual Boolean PoseQuestion(CharPtr& query);
  133.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  134.     virtual const char* GetKindName();
  135. };
  136.  
  137.  
  138.  
  139. class DTelnetGopher : public DGopher {
  140. public:
  141.     DTelnetGopher( char ctype, const char* link);
  142.     DTelnetGopher();
  143.     DTelnetGopher( DTelnetGopher* aGopher);
  144.     virtual    void Initialize();    // override 
  145.     virtual DObject* Clone();
  146.     virtual void InfoTask();
  147.     virtual void promptUser(char* msg1, char* msg2);
  148.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  149.     virtual const char* GetKindName();
  150. };
  151.  
  152. class DBinhexGopher : public DGopher {
  153. public:
  154.     Boolean fGotBinhexKey;
  155.     unsigned char     *fHqxbuf, *fBufptr, *fBufend, *fBufstart;
  156.     long     fLinecount, fFilecount;
  157.     long     fSavestate, fTotalbytes, fSaveRunLength, fSaveNibble;
  158.     short fDecodeStatus;
  159.  
  160.     void hqxFini();
  161.     void hqxInit();
  162.     short fill_hqxbuf();
  163.     long check_hqx_crc();
  164.     short hqx2FinderInfo( char *binfname, long *fauth, long *ftype, 
  165.                                         unsigned long *hqx_datalen, unsigned long  *hqx_rsrclen); 
  166.     short hqx2fork( short fileref, unsigned long nbytes);
  167.  
  168.     DBinhexGopher( char ctype, const char* link);
  169.     DBinhexGopher();
  170.     DBinhexGopher( DBinhexGopher* aGopher);
  171.     virtual    void Initialize();    // override 
  172.     virtual DObject* Clone();
  173.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  174.     virtual const char* GetKindName();
  175. };
  176.     
  177. #if FIX_LATER
  178. class DCSOPhoneBookGopher : public DTextGopher {
  179. public:
  180.     DCSOPhoneBookGopher( char ctype, const char* link);
  181.     DCSOPhoneBookGopher();
  182.     DCSOPhoneBookGopher( DCSOPhoneBookGopher* aGopher);
  183.     virtual    void Initialize();    // override 
  184.     virtual DObject* Clone();
  185.     virtual void ReadALine();  // override 
  186.     virtual void ReadAChunk( long maxchunk);  // override 
  187.     virtual void addToInfo( char *cp, short len);
  188.     virtual void addQuery( long qname, char* query, DWindow* aWind);
  189.     virtual void InfoTask();
  190.     virtual Boolean queryUser( CStr255& query);
  191.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  192.     virtual const char* GetKindName();
  193. };
  194. #endif
  195.  
  196. #if FIX_LATER
  197. class CWhoisPhoneBookGopher : public CTextGopher {
  198. public:
  199.     CWhoisPhoneBookGopher( char ctype, const char* link);
  200.     CWhoisPhoneBookGopher();
  201.     CWhoisPhoneBookGopher( CWhoisPhoneBookGopher* aGopher);
  202.     virtual    void Initialize();    // override 
  203.     virtual void InfoTask();
  204.     virtual CGopher* Clone();
  205.     virtual Boolean PoseQuestion(CStr255& query);
  206.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  207.     virtual const char* GetKindName();
  208. };
  209. #endif
  210.  
  211. #if FIX_LATER
  212. class CUuencodeGopher : public CTextGopher {
  213. public:
  214.     CUuencodeGopher( char ctype, const char* link);
  215.     CUuencodeGopher();
  216.     CUuencodeGopher( CUuencodeGopher* aGopher);
  217.     virtual    void Initialize();    // override 
  218.     virtual CGopher* Clone();
  219.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  220.     virtual const char* GetKindName();
  221. };
  222. #endif
  223.  
  224.     
  225. class DSoundGopher : public DBinaryGopher {
  226. public:
  227.     static long    kMacType, kMacSire;
  228.     static char* kSuffix;
  229.     DSoundGopher( char ctype, const char* link);
  230.     DSoundGopher();
  231.     DSoundGopher( DSoundGopher* aGopher);
  232.     virtual    void Initialize();    // override 
  233.     virtual DObject* Clone();
  234.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  235.     virtual const char* GetKindName();
  236.     static void InitSignature();     
  237. };
  238.             
  239.  
  240. class DImageGopher : public DBinaryGopher {
  241. public:
  242.     static long    kMacType, kMacSire;
  243.     static char* kSuffix;
  244.     DImageGopher( char ctype, const char* link);
  245.     DImageGopher();
  246.     DImageGopher( DImageGopher* aGopher);
  247.     virtual DObject* Clone();
  248.     virtual    void Initialize();    // override 
  249.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  250.     virtual const char* GetKindName();
  251.     static void InitSignature();     
  252. };
  253.  
  254. class DMovieGopher : public DBinaryGopher {
  255. public:
  256.     static long    kMacType, kMacSire;
  257.     static char* kSuffix;
  258.     DMovieGopher( char ctype, const char* link);
  259.     DMovieGopher();
  260.     DMovieGopher( DMovieGopher* aGopher);
  261.     virtual DObject* Clone();
  262.     virtual    void Initialize();    // override 
  263.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  264.     virtual const char* GetKindName();
  265.     static  void InitSignature();     
  266. };
  267.  
  268.  
  269. class DNoteGopher : public DGopher {
  270. public:
  271.     DNoteGopher( char ctype, const char* link);
  272.     DNoteGopher();
  273.     DNoteGopher( DNoteGopher* aGopher);
  274.     virtual DObject* Clone();
  275.     virtual    void Initialize();    // override 
  276.     virtual void InfoTask();
  277.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  278.     virtual const char* GetKindName();
  279. };
  280.  
  281. class DHtmlGopher : public DTextGopher {
  282. public:
  283.     DHtmlGopher( char ctype, const char* link);
  284.     DHtmlGopher();
  285.     DHtmlGopher( DHtmlGopher* aGopher);
  286.     virtual    void Initialize();    // override 
  287.     virtual DObject* Clone();
  288.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  289.     virtual const char* GetKindName();
  290. };
  291.  
  292. class DMailGopher : public DGopher {
  293. public:
  294.     DMailGopher( char ctype, const char* link);
  295.     DMailGopher();
  296.     DMailGopher( DMailGopher* aGopher);
  297.     virtual DObject* Clone();
  298.     virtual    void Initialize();    // override 
  299.     virtual    void OpenQuery();    // override 
  300.     virtual void InfoTask();
  301.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  302.     virtual const char* GetKindName();
  303. };
  304.  
  305. class DHTTPGopher : public DGopher {
  306. public:
  307.     DHTTPGopher( char ctype, const char* link);
  308.     DHTTPGopher();
  309.     DHTTPGopher( DHTTPGopher* aGopher);
  310.     virtual DObject* Clone();
  311.     virtual    void Initialize();    // override 
  312.     virtual    void OpenQuery();    // override 
  313.     virtual void InfoTask();
  314.     virtual void DrawIcon( Nlm_RecT& area, short size); // override 
  315.     virtual const char* GetKindName();
  316. };
  317.  
  318.  
  319.  
  320. #endif
  321.